473,435 Members | 1,484 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,435 software developers and data experts.

MouseDown Event

JJ
Hi All,

I need to create a MouseDown event for a picture box . Am I doing the
following right?

pictureBox.MouseDown += new
System.WinForms.MouseEventHandler(pictureBox_Mouse Down)

Then

Create Event
public void pictureBox_OnMouseDown(object sender,
System.WinForms.MouseEventArgs e)
{

// code etc....

}

Thanks,

JJ
Nov 13 '05 #1
2 16270
What do you mean by, " Then Create Event"? Your code is ambiguous. When
you add the event handler to the pictureBox, you pass in the function
pictureBox_MouseDown, but your function is called pictureBox_OnMouseDown.
Is this a typo?

The code should look like the following, assuming that pictureBox and
pictureBox_MouseDown exist in the same class:

// in initialization (perhaps in the constructor) add event handler to the
PictureBox
// This actually creates the event delegate and adds it to the list of
MouseDown delegates for pictureBox.
// When the MouseDown event is raised by pictureBox(i.e. when you press a
mouse button on the pictureBox),
// the function pictureBox_MouseDown will get executed.
pictureBox.MouseDown += new MouseEventHandler(this.pictureBox_MouseDown)

// the MouseDown event handler
private void pictureBox_MouseDown(object sender, MouseEventArgs e)
{
// do whatever you need to do.
}

Hope this helps,
Jerome
"JJ" <jm***@bellatlantic.net> wrote in message
news:uS**************@TK2MSFTNGP12.phx.gbl...
Hi All,

I need to create a MouseDown event for a picture box . Am I doing the
following right?

pictureBox.MouseDown += new
System.WinForms.MouseEventHandler(pictureBox_Mouse Down)

Then

Create Event
public void pictureBox_OnMouseDown(object sender,
System.WinForms.MouseEventArgs e)
{

// code etc....

}

Thanks,

JJ

Nov 13 '05 #2

pictureBox.MouseDown += new
System.WinForms.MouseEventHandler(pictureBox_Mouse Down)
public void pictureBox_OnMouseDown(object sender,
System.WinForms.MouseEventArgs e)

// No! use the same name:
pictureBox_MouseDown
Nov 13 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Deborah V. Gardner | last post by:
I have a list box and would like to point to an item and have a textbox popup referencing a column in the list box. On the list box's MouseDown event I have the following Dim strFullText ...
1
by: GregM | last post by:
I have a read only datagrid that is designed to coordinate itself with textboxes. When the user clicks on a row in the datagrid, detailed data for that row is displayed for editing in the...
7
by: Scott Mackay | last post by:
Hi, I'm using visual studio dotnet 2002 programming in vb can anyone tell me how I can handle the mousedown event for pictureboxes I create dynamically at runtime? I've tried setting the...
4
by: rsmith | last post by:
How can I capture the MouseDown event on a Label ? I entered thr following code and got a " cannot handle Event 'MouseDown' because they do not have the same signature." Private Sub...
1
by: Merlin | last post by:
I have created a UserControl which has a label; what I wish to do is place this UserControl on a form and then trap the Mouse Down event, whenever someone clicks my control. My problem is that the...
2
by: Rob | last post by:
How can I fix the following warning warning BC40004: sub 'MouseDown' conflicts with event 'MouseDown' in the base class 'Control' and so should be declared 'Shadows'. This warning appears...
1
by: Alan | last post by:
i have a form with a label on it Private Sub Label1_mousedown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Label1.MouseDown ' do stuff End Sub ...
1
by: JDeats | last post by:
It appears the WinForm MouseDown and MouseUp event handlers are not working properly. In the "bare bones" sample application below, Form1_MouseUp gets called even through the mouse button remains...
6
by: jpatchak | last post by:
Hello, I am trying to create a context menu for right clicking on a TreeView control (for deleting, etc...), using either the MouseDown or MouseUp event. When I put following code in: Private...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.